package cn.micai.base.collections;

import java.util.Iterator;
import java.util.concurrent.ConcurrentHashMap;

/**
 * 描述：
 * <p>
 *
 * @author: 赵新国
 * @date: 2018/6/11 15:59
 */
public class ConcurrentHashMapStructure {

    public static void main(String [] args) {

        Country india = new Country("India",1000);
        Country japan = new Country("Japan",10000);
        Country france = new Country("France",2000);
        Country russia = new Country("Russia",20000);

        ConcurrentHashMap<Country, String> countryCapitalMap = new ConcurrentHashMap<>();
        countryCapitalMap.put(india, "Delhi");
        countryCapitalMap.put(japan, "Tokyo");
        countryCapitalMap.put(france, "Paris");
        countryCapitalMap.put(russia, "Moscow");

        Iterator<Country> iterator = countryCapitalMap.keySet().iterator();
        // put debug point at this line
        while (iterator.hasNext()) {
            Country country = iterator.next();
            String capital = countryCapitalMap.get(country);
            System.out.println(country.getName() + " " + capital);
        }
    }
}
